<template>
  <div class="edit-container">
    <el-form v-loading="formLoading" ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="用户头像" >
        <img :src="form.avatar" class="img" v-if="form.avatar">
        <div v-else>暂无</div>
      </el-form-item>
      <el-form-item label="用户昵称:" >
        <div>{{form.name}}</div>
      </el-form-item>
      <el-form-item label="用户电话:" >
        <div>{{form.phone}}</div>
      </el-form-item>
      <el-form-item label="更新时间:" >
        <div>{{form.updateTime}}</div>
      </el-form-item>
      <el-form-item label="创建时间:" >
        <div>{{form.createTime}}</div>
      </el-form-item>
      <el-form-item>
        <el-button @click="close">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import {detail, save} from "@/api/user";
import {getForm} from "@/utils/utils";
import UploadFile from "@/components/File/UploadFile.vue";
import Tinymce from "@/components/Tinymce/index.vue";

export default {
  components: {Tinymce, UploadFile},
  props:{
    id:{
      default:null
    }
  },
  data(){
    return{
      form:{
        id:null,
        file:'',
        content:'',
        status:1,
      },
      rules:{
        file: [{ required: true, message: '请上传文件', trigger: ['blur'] }],
      },
      roles:[],
      saveLoading:false,
      formLoading:false,
      uploads:{
        show:false,
        multiple:true,
      }
    }
  },
  mounted() {
    if(this.id){
      this.getDetail();
    }
  },
  methods:{
    getFile(fileList){
      // console.log(fileList);
    },
    getDetail(){
      this.formLoading=true
      detail(this.id).then(res=>{
        // getForm(res,this.form);
        this.form = res
      }).finally(()=>{
        this.formLoading=false;
      })
    },
    handlerSubmit(){
      if(this.saveLoading||this.formLoading){
        return;
      }
      /*this.$refs.form.validate(valid=>{
        if(!valid)return;
        this.saveLoading=true;
        save(this.form).then(()=>{
          this.$message.success('保存成功');
          this.close();
        }).finally(()=>{
          this.saveLoading=false
        })
      })*/
    },
    close(){
      this.$emit('hideEditDialog')
    }
  }
}
</script>

<style scoped lang="scss">
::v-deep{
  .el-upload{
  }
}
.img{
  width: 80px;
  height: 80px;
  border-radius: 100px;
}
</style>
